package org.numb.model;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.numb.common.validator.UserValid;

@Getter
@Setter
@ToString
@UserValid(prefix = "Sa")
public class User {
    @NotBlank
    @Length(max = 64)
    @Pattern(regexp = "^[a-z0-9A-Z_-]*$")
    private String id;

    @Length(max = 64)
    @Pattern(regexp = "^[a-z0-9A-Z_-]*$")
    private String name;

    @Range(min = 0, max = 200)
    private int age;

    // 未增加@Valid注解时校验不生效
    @Valid
    private Address address;
}
